<template>
  <div class="home app_content">
    <!-- 导航栏 -->
    <div class="header_body">
      <header-nav :leftArrow="true" titelText="锻炼"></header-nav>
    </div>
    <div class="top-3">
      <div class="each" v-for="plan in info.plans" @click="playVideo(plan)">
        <div>{{plan.title}}</div>
        <img :src="plan.cover" />
      </div>
    </div>
    <van-dialog v-model:show="info.show" :title="info.cur.title" show-cancel-button>
      <video 
        style="width: 100%;height: 300px;"
        ref="videoPlayer"
        :src="info.cur.src" 
        controls 
      >
        您的浏览器不支持 video 标签。
      </video>
    </van-dialog>
    <!-- 底部 -->
    <div class="footer_body">
      <footer-nav></footer-nav>
    </div>
  </div>
</template>

<script setup name="Video">
import { getVideo } from "@/api/http.js";
const router = useRouter();
const { useHome } = $globalStore;
const route = useRoute();

let info = reactive({
    plans: [],
    title: '',
    show: false,
    cur: {}
})

const playVideo = (plan) => {
  info.show = true
  info.cur = plan;
}


onMounted(() => {
	console.log(route.params)
  info.title = route.params.type
  getVideo().then(res => {
    let total = res.data.filter(v => v.type == info.title)
    info.plans = total
  })
});
</script>

<style lang="less" scoped>
.home {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background-color: #f4f4f4;

}
.circles {
  padding: 20px 0;
  display: flex;
  justify-content: space-around;

  .circle {
    display: flex;
    flex-direction: column;
    img {
      width: 50px;
      height: 50px;
      border-radius: 50%;
      margin-left: 5px;
    }
    div {
      width: 60px;
      text-align: center;
      margin-top: 12px;
      font-weight: bold;
      font-size: 14px;
    }
  }
}
.top-3 {
  padding: 0 12px;

  .each {
    width: calc(100% - 40px);
    margin: 10px 0;
    background: #fff;
    border-radius: 6px;
    display: flex;
    align-items: center;
    font-size: 14px;
    justify-content: space-between;
    padding: 20px;
     div {

     }
     img {
      width: 50px;
      height: 50px;
     }
  }
}
</style>
